//
//  YTBeautyViewController.m
//  YUNT
//
//  Created by 小萌 on 2017/11/14.
//  Copyright © 2017年 梁炜东. All rights reserved.
//

#import "YTBeautyViewController.h"
#import "YTBeautyHeadView.h"
@interface YTBeautyViewController ()
@property (nonatomic, strong) YTBeautyHeadView *headView;
@end

@implementation YTBeautyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"美颜";
    // Do any additional setup after loading the view.
    [self loadData];
}
- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    self.tableView.tableHeaderView = self.headView;
}
- (void)loadData
{
    if (publicModel.isBeauty) {
        
        YTSetModel *model1 = [[YTSetModel alloc] init];
        model1.name = @"嫩肤";
        model1.isSelected = publicModel.videoFilter == 1?YES:NO;
        YTSetModel *model2 = [[YTSetModel alloc] init];
        model2.name = @"和煦";
        model2.isSelected = publicModel.videoFilter == 2?YES:NO;

        YTSetModel *model3 = [[YTSetModel alloc] init];
        model3.name = @"午夜";
        model3.isSelected = publicModel.videoFilter == 3?YES:NO;

        YTSetModel *model4 = [[YTSetModel alloc] init];
        model4.name = @"阳光";
        model4.isSelected = publicModel.videoFilter == 4?YES:NO;
        self.dataArr = @[model1,model2,model3,model4];
        
    }else{
        self.dataArr = @[];
    }
    [self.tableView reloadData];
}
- (YTBeautyHeadView *)headView
{
    if (!_headView) {
        _headView = [YTBeautyHeadView loadViewForNib];
        _headView.frame = CGRectMake(0, 0, ScreenWidth, 62);
        _headView.beautySwitch.on = publicModel.isBeauty;
        IMP_BLOCK_SELF(YTBeautyViewController);
        _headView.handler = ^(id sender) {
            if ([sender boolValue] == NO) {
                publicModel.videoFilter = 0;
            }
            [deviceManager BeautyFilter:[sender boolValue]];
            [block_self loadData];

        };
    }
    return _headView;
}
- (void)tableView:(UITableView *)tableView atIndexPath:(NSIndexPath *)indexPath
{
    [super tableView:tableView atIndexPath:indexPath];
    [deviceManager setVideoFilter:(int)indexPath.row + 1];
    BlockCallWithOneArg(self.handler, nil);
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
